home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Beta / Quicktime 2.0 Beta.iso / Extensions / Macintosh Easy Open / Documentation / Developer / Interfaces / PInterfaces / TranslationExtensions.p < prev   
Encoding:
Text File  |  1993-04-28  |  5.9 KB  |  186 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        TranslationExtensions.p
  3.  
  4.     Contains:    Pascal Interface definitions for translation extension writers.
  5.  
  6.     Copyright:    © 1990-1993 by Apple Computer, Inc., all rights reserved.
  7. }
  8.  
  9. {$IFC UNDEFINED UsingIncludes}
  10.     {$SETC UsingIncludes := 0}
  11. {$ENDC}
  12.  
  13. {$IFC NOT UsingIncludes}
  14.     UNIT TranslationExtensions;
  15.     INTERFACE
  16. {$ENDC}
  17.  
  18. {$IFC UNDEFINED TranslationExtensions}
  19. {$SETC TranslationExtensions := 1}
  20.  
  21. {$I+}
  22. {$SETC TranslationExtensionsIncludes := UsingIncludes}
  23. {$SETC UsingIncludes := 1}
  24. {$IFC UNDEFINED UsingMemory}
  25. {$I $$Shell(PInterfaces)Memory.p}
  26. {$ENDC}
  27. {$IFC UNDEFINED UsingFiles}
  28. {$I $$Shell(PInterfaces)Files.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED UsingQuickdraw}
  31. {$I $$Shell(PInterfaces)Quickdraw.p}
  32. {$ENDC}
  33. {$IFC UNDEFINED UsingComponents}
  34. {$I $$Shell(PInterfaces)Components.p}
  35. {$ENDC}
  36.  
  37. {$IFC UNDEFINED UsingTranslationExtensions}
  38.     {$I TranslationExtensions.p}
  39. {$ENDC}
  40.  
  41. {$SETC UsingIncludes := TranslationExtensionsIncludes}
  42.  
  43.  
  44. CONST
  45.     kSupportsFileTranslation = 1;
  46.     kSupportsScrapTranslation = 2;
  47.     
  48.     { special error codes that DoTranslateFile can return }
  49.     {        userCanceledErr    = -128; }            {user hit cancel button in progress dialog, or error handled by extension }
  50.     invalidTranslationPathErr = -3025;            {srcType to dstType is not a valid path         ••• move into Errors.h    }
  51.     couldNotParseSourceFileErr = -3026;            {the source document does not contain srcType    ••• move into Errors.h    }
  52.     
  53.     { translation attributes }
  54.     taDstDocNeedsResourceFork = 1;            
  55.     taDstIsAppTranslation = 2;
  56.     
  57.     { ComponentMgr selectors for routines }
  58.     kTranslateGetFileTranslationList = 0;        { component selectors }
  59.     kTranslateIdentifyFile = 1;
  60.     kTranslateTranslateFile = 2;
  61.     kTranslateGetScrapTranslationList = 10;        { skip to scrap routines }
  62.     kTranslateIdentifyScrap = 11;
  63.     kTranslateTranslateScrap = 12;
  64.  
  65.  
  66. TYPE
  67.  
  68.     { better names for 4-char codes }
  69.     FileType = OSType;
  70.     ScrapType = ResType;
  71.         
  72.     TranslationAttributes = LONGINT;
  73.     FileTypeSpec = RECORD
  74.                         format:            FileType;
  75.                         hint:             LONGINT;
  76.                         flags:             TranslationAttributes;            { taDstDocNeedsResourceFork, taDstIsAppTranslation }
  77.                         catInfoType:    OSType;
  78.                         catInfoCreator: OSType;
  79.                     END;
  80.     
  81.     FileTranslationListPtr = ^FileTranslationList;
  82.     FileTranslationListHandle = ^FileTranslationListPtr;
  83.     FileTranslationList =     RECORD
  84.                                 modDate:    LONGINT;
  85.                                 groupCount: LONGINT;
  86.                                 { group1SrcCount: LONGINT; }
  87.                                 { group1SrcEntrySize: LONGINT = sizeof(FileTypeSpec); }
  88.                                 { group1SrcTypes = ARRAY[group1SrcCount] OF FileTypeSpec; }
  89.                                 { group1DstCount: LONGINT;
  90.                                 { group1DstEntrySize: LONGINT = sizeof(FileTypeSpec); }
  91.                                 { group1DstTypes = ARRAY[group1DstCount] OF FileTypeSpec; }
  92.                             END;
  93.         
  94.     ScrapTypeSpec = RECORD
  95.                         format: ScrapType;
  96.                         hint:     LONGINT;
  97.                     END;
  98.         
  99.     ScrapTranslationListPtr = ^ScrapTranslationList;
  100.     ScrapTranslationListHandle = ^ScrapTranslationListPtr;
  101.     ScrapTranslationList =  RECORD
  102.                                 modDate:     LONGINT;
  103.                                 groupCount: LONGINT;
  104.                                 { group1SrcCount: LONGINT; }
  105.                                 { group1SrcEntrySize: LONGINT = sizeof(ScrapTypeSpec); }
  106.                                 { group1SrcTypes = ARRAY[group1SrcCount] OF ScrapTypeSpec; }
  107.                                 { group1DstCount: LONGINT;
  108.                                 { group1DstEntrySize: LONGINT = sizeof(ScrapTypeSpec); }
  109.                                 { group1DstTypes = ARRAY[group1DstCount] OF ScrapTypeSpec; }
  110.                             END;
  111.     
  112.     { definition of callbacks to update progress dialog }
  113.     TranslationRefNum = LONGINT;
  114.  
  115. {
  116. //////////////////////////////////////////////////////////////////////////////////////////////
  117. //
  118. // This routine sets the advertisement in the top half of the progress dialog.
  119. // It is called once at the beginning of your DoTranslateFile routine.
  120. //
  121. // Enter:    refNum            Translation reference supplied to DoTranslateFile.
  122. //            advertisement    A handle to the picture to display.  This must be non-purgable.
  123. //                            Before returning from DoTranslateFile, you should dispose
  124. //                            of the memory.  (Normally, it is in the temp translation heap
  125. //                            so it is cleaned up for you.)
  126. //
  127. // Exit:    returns            noErr, paramErr, or memFullErr
  128. //
  129. }
  130. FUNCTION SetTranslationAdvertisement( refNum        : TranslationRefNum;
  131.                                       advertisement    : PicHandle): OSErr;
  132.      INLINE $7002, $ABFC; 
  133.  
  134.  
  135. {
  136. //////////////////////////////////////////////////////////////////////////////////////////////
  137. //
  138. // This routine updates the progress bar in the progress dialog.
  139. // It is only called from within your DoTranslateFile routine.
  140. // It should be called often, so that the user will get feedback if he tries to cancel.
  141. //
  142. // Enter:    refNum        translation reference supplied to DoTranslateFile.
  143. //            progress    percent complete (0-100)
  144. //
  145. // Exit:    canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  146. //            returns        noErr, paramErr, or memFullErr
  147. //
  148. }
  149. FUNCTION UpdateTranslationProgress(refNum        : TranslationRefNum;
  150.                                     percentDone    : INTEGER;
  151.                                 VAR canceled    : Boolean): OSErr;
  152.      INLINE $7001, $ABFC; 
  153.  
  154.  
  155. { implement these if you are writing a File Translation Extension }
  156. {
  157. FUNCTION DoGetFileTranslationList(self: ComponentInstance; translationList: FileTranslationListHandle) : ComponentResult;
  158.  
  159. FUNCTION DoIdentifyFile(self: ComponentInstance; theDoc: FSSpec; VAR docKind: FileType) : ComponentResult;
  160.  
  161. FUNCTION DoTranslateFile(self: ComponentInstance; refNum: TranslationRefNum;
  162.                             srcDoc: FSSpec; srcType: FileType; srcTypeHint: LONGINT; 
  163.                             dstDoc: FSSpec; dstType: FileType; dstTypeHint: LONGINT) : ComponentResult;
  164. }
  165.  
  166.  
  167.  
  168. { implement these if you are writing a Scrap Translation Extension }
  169. {
  170. FUNCTION DoGetScrapTranslationList(self: ComponentInstance; list: ScrapTranslationListHandle) : ComponentResult;
  171.  
  172. FUNCTION DoIdentifyScrap(self: ComponentInstance; dataPtr: Ptr; dataLength: Size;
  173.                             VAR dataFormat: ScrapType) : ComponentResult;
  174.  
  175. FUNCTION DoTranslateScrap(self: ComponentInstance; refNum: TranslationRefNum;
  176.                             srcDataPtr: Ptr; srcDataLength: Size; srcType: ScrapType;
  177.                             srcTypeHint: LONGINT; dstData: Handle; dstType: ScrapType;
  178.                             dstTypeHint: LONGINT) : ComponentResult;
  179. }
  180.  
  181. {$ENDC}    { UsingTranslationExtensions }
  182.  
  183. {$IFC NOT UsingIncludes}
  184.     END.
  185. {$ENDC}
  186.